﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using TorchView.Composition;
using TorchView.Game;
using System.Windows.Input;
using TorchView.Windows;

namespace TorchView.SharedStashEditor.ViewModels
{
    public class EditEffectViewModel : DependencyObject, IEditEffectViewModel
    {
        public EditEffectViewModel(IDialogView<IEditEffectViewModel> view)
        {
            View = view;
            view.Model = this;
            CancelCommand = new DirectCommand(o => { View.DialogResult = false; View.Close(); });
            OKCommand = new DirectCommand(o => { View.DialogResult = true; View.Close(); });
        }

        public static readonly DependencyProperty EffectProperty =
                DependencyProperty.Register("effect", typeof(Effect), typeof(EditEffectViewModel), new UIPropertyMetadata(null));

        public IDialogView<IEditEffectViewModel> View { get; private set; }
        public ICommand CancelCommand { get; private set; }
        public ICommand OKCommand { get; private set; }

        public Effect effect
        {
            get { return (Effect)GetValue(EffectProperty); }
            set { SetValue(EffectProperty, value); }
        }

        public List<DamageSourceType> DamageSourceTypes
        {
            get
            {
                Type enumType = typeof(DamageSourceType);

                Array enumValArray = Enum.GetValues(enumType);

                List<DamageSourceType> enumValList = new List<DamageSourceType>(enumValArray.Length);

                foreach (object val in enumValArray)
                {
                    enumValList.Add((DamageSourceType)Enum.Parse(enumType, val.ToString()));
                }

                return enumValList;
            }
        }     
    }
}
